package com.bw.flinkstreaming.state.job4;
import com.bw.flinkstreaming.state.job3.MapStateWithCountAvg;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 *
 */
public class ReducingStateWithCountAvgTest {
    public static void main(String[] args) throws  Exception{
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);

        // Tuple2.of(6L, 9L), Tuple2.of(5L, 6L),Tuple2.of(6L, 3L), Tuple2.of(6L, 4L),
        DataStreamSource<Tuple2<Long, Long>> dataStreamSource =
                env.fromElements(Tuple2.of(5L, 12L), Tuple2.of(5L, 15L),Tuple2.of(5L, 6L),Tuple2.of(5L, 7L));
        dataStreamSource
                .keyBy(0)
                .flatMap(new ReducingStateWithCountAvg())
                .print();
        env.execute("ReducingStateWithCountAvgTest");
    }
}